package cn.itcast.servlet;

import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.itcast.bean.Users;
import cn.itcast.service.UserService;
import cn.itcast.utils.JdbcUtils;

public class AddServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		Users u = new Users();
		u.setId(JdbcUtils.makeId());
		u.setName(request.getParameter("name"));
		u.setPassword(request.getParameter("password"));
		u.setEmail(request.getParameter("email"));
		u.setBirthday(request.getParameter("birthday"));
		
//		Enumeration e = request.getParameterNames();
//		while(e.hasMoreElements()){
//			String name = (String) e.nextElement();
//			String value = request.getParameter(name);
//			
//		}
		UserService us = new UserService() ;
		us.adduserdao(u);
		
		
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);

	}

}
